<?php
if(!empty($_POST) AND !isset($_POST['Entry']))
{
	if(isset($_POST['Grumble'])) { UpdateUnit('Grumble', $_POST['Grumble']); }
	if(isset($_POST['MgBike'])) { UpdateUnit('MgBike', $_POST['MgBike']); }
	if(isset($_POST['PanzerLeicht'])) { UpdateUnit('PanzerLeicht', $_POST['PanzerLeicht']); }
	if(isset($_POST['PanzerSchwer'])) { UpdateUnit('PanzerSchwer', $_POST['PanzerSchwer']); }
	if(isset($_POST['Turtle'])) { UpdateUnit('Turtle', $_POST['Turtle']); }
	if(isset($_POST['Weasel'])) { UpdateUnit('Weasel', $_POST['Weasel']); }
	if(isset($_POST['Eagle'])) { UpdateUnit('Eagle', $_POST['Eagle']); }
	if(isset($_POST['Eraser'])) { UpdateUnit('Eraser', $_POST['Eraser']); }
	if(isset($_POST['Hovercraft'])) { UpdateUnit('Hovercraft', $_POST['Hovercraft']); }
	if(isset($_POST['Shadow'])) { UpdateUnit('Shadow', $_POST['Shadow']); }
	if(isset($_POST['BazookaGuy'])) { UpdateUnit('BazookaGuy', $_POST['BazookaGuy']); }
	if(isset($_POST['Commando'])) { UpdateUnit('Commando', $_POST['Commando']); }
	if(isset($_POST['Elitemarine'])) { UpdateUnit('Elitemarine', $_POST['Elitemarine']); }
	if(isset($_POST['Sprengmeister'])) { UpdateUnit('Sprengmeister', $_POST['Sprengmeister']); }
	if(isset($_POST['Scout'])) { UpdateUnit('Scout', $_POST['Scout']); }
	if(isset($_POST['Soeldner'])) { UpdateUnit('Soeldner', $_POST['Soeldner']); }
	if(isset($_POST['Spacemarine'])) { UpdateUnit('Spacemarine', $_POST['Spacemarine']); }
	if(isset($_POST['Airhunter'])) { UpdateUnit('Airhunter', $_POST['Airhunter']); }
}
$result = RequestData('einheiten');
$building = RequestData('buildings');
$science = RequestData('forschung');
$lager = RequestData('lager');
?>
<form method="post">
	<table class="buildings" style="table-layout: fixed; width: 720px;">
		<colgroup>
			<col style="width:115px;">
			<col style="width:auto;">
			<col style="width:100px">
		</colgroup>
		<thead>
			<td>Kaserne</td>
		</thead>
		<?php
			$con = Connect();
			$check = mysql_query("SELECT * FROM kaserne_build ORDER BY KasernenLevel");
			while($unit = mysql_fetch_object($check))
			{
				$lock = array(false, false, false, false, false);
				if($building['Kaserne'] > $unit->KasernenLevel)
				{
					echo '<tr><th><img src="../Game/template/Images/truppen/'.$unit->Name.'.png"></th>';
					echo '<th><p>'.$unit->Name.'['.$result[$unit->Name].']</p><p>'.$unit->Description.'</p>';
					echo '<p>Zeit: '.$unit->Timelimit.'</p><p>Ben&ouml;tigt: ';
					if($unit->Munition != 0)
					{
						if($science['Munition'] < $unit->Munition)
						{ 
							echo '<b style="color:#FF0000;"> Munitions Entwicklung Stufe '.$unit->Munition.'</b>,'; 
							$lock[0] = true;
						}else{ 
							echo '<b style="color:#00FF00;"> Munitions Entwicklung Stufe '.$unit->Munition.'</b>,'; 
						}
					}
					if($unit->Panzerung != 0)
					{
						if($science['Panzer'] < $unit->Panzerung)
						{ 
							echo '<b style="color:#FF0000;"> Panzer Entwicklung Stufe '.$unit->Panzerung.'</b></p>'; 
							$lock[1] = true;
						}else{ 
							echo '<b style="color:#00FF00;"> Panzer Entwicklung Stufe '.$unit->Panzerung.'</b></p>'; 
						}
					}
					if($unit->Hydraulik != 0)
					{
						if($science['Hydraulik'] < $unit->Hydraulik)
						{ 
							echo '<b style="color:#FF0000;"> Hydraulik Stufe '.$unit->Hydraulik.'</b>,'; 
							$lock[2] = true;
						}else{ 
							echo '<b style="color:#00FF00;"> Hydraulik Stufe '.$unit->Hydraulik.'</b>, '; 
							
						}
					}
					if($unit->Maschinbau != 0)
					{
						if($science['Maschine'] < $unit->Maschinbau)
						{ 
							echo '<b style="color:#FF0000;"> Maschinbau Stufe '.$unit->Maschinbau.'</b>,';
							$lock[3] = true;							
						}else{ 
							echo '<b style="color:#00FF00;"> Maschinbau Stufe '.$unit->Maschinbau.'</b>,'; 
						}
					}
					if($lager[$unit->Leereinheit] < 1)
					{
						echo '<b style="color:#FF0000;"> '.$unit->Leereinheit.'</b></p>';
						$lock[4] = true;
					}else{
						echo '<b style="color:#00FF00;"> '.$unit->Leereinheit.'</b></p>';
					}
					echo '</th><th><p>Einheiten: </p><p><input type="number" name="'.$unit->Name.'" value="0" min="0" max="50" style="width:80px;" ';
					if($lock[0] == true || $lock[1] == true || $lock[2] == true || $lock[3] == true || $lock[4] == true) echo 'disabled';
					echo '></p><br><p><input type="submit" name="unit"></p></th></tr>';
				}
			}
			Close($con);
		?>
	</table>
</form>